#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


#
#	Scratch workspace.
#

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext import db

import time
import datetime
import header
import footer
import urllib2
import simplejson
#import json
import Stalker

class Balazs(webapp.RequestHandler):
	def get(self):
		self.response.out.write(header.head)
		self.response.out.write('''  
		 <div class="content">
			<div class="content_resize">
				
					<div class="article">
						<div class="clr"></div>
		'''   )     

		#t_limit = 
		
		
		
		
		t_database = db.GqlQuery("SELECT * FROM GeoTweet_model \
		ORDER BY created_at DESC LIMIT 10" )
		self.response.out.write("<table width=100% border=3>")
		self.response.out.write("<tr>")
		self.response.out.write("<td>screen_name</td>")
		self.response.out.write("<td>id_str</td>")
		self.response.out.write("<td>real_name</td>")
		self.response.out.write("<td>geo</td>")
		self.response.out.write("<td>location</td>")
		self.response.out.write("<td>created_at</td>")
		self.response.out.write("<td>text</td>")
		self.response.out.write("</tr>")
		
		for _tweet in t_database:
			self.response.out.write("<tr>")
			self.response.out.write("<td>"+str(_tweet.screen_name)+"</td>")
			self.response.out.write("<td>"+str(_tweet.id_str)+"</td>")
			self.response.out.write("<td>"+str(_tweet.real_name)+"</td>")
			self.response.out.write("<td>"+str(_tweet.geo)+"</td>")
			self.response.out.write("<td>"+str(_tweet.location)+"</td>")
			self.response.out.write("<td>"+str(_tweet.created_at)+"</td>")
			self.response.out.write("<td>"+str(_tweet.text)+"</td>")
			self.response.out.write("</tr>")	
		self.response.out.write("</table>")
			#self.response.out.write(str(_tweet.created_at)+"<br>")
			#self.response.out.write(_tweet.geo+"|||")
			#self.response.out.write(_tweet.coordinates+"<br>")
	
	
		
			
		
		self.response.out.write('''
        </div>
      </div>
      <div class="sidebar">
        <div class="gadget">
          
          <div class="clr"></div>
          
        </div>
        <div class="gadget">
          <div class="clr"></div>
          </ul>
        </div>
      </div>
      <div class="clr"></div>
    </div>
  </div>
  <div class="fbg">
    <div class="fbg_resize">
      <div class="col c1">
        </div>
      <div class="col c3">
        </div>
      <div class="clr"></div>
    </div>
  </div>
		''')		
	        self.response.out.write(footer.foot)

if __name__ == '__main__':
    main()